package com.taotao.portal.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.converter.json.MappingJacksonValue;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.taotao.common.pojo.TaotaoResult;
import com.taotao.pojo.TbUser;
import com.taotao.portal.service.LogService;

@Controller
public class UserController {
	@Autowired
	private LogService logService;

	@RequestMapping(value = "/user/token/{token}")
	@ResponseBody
	public Object getUserByToken(@PathVariable String token, String callback) {

		TbUser user = null;
		try {
			user = logService.isLog(token);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			user = null;

		}
		if (callback == null || callback == "") {
			return TaotaoResult.ok(user);
		} else {
			MappingJacksonValue mappingJacksonValue = new MappingJacksonValue(TaotaoResult.ok(user));
			mappingJacksonValue.setJsonpFunction(callback);
			return mappingJacksonValue;
			
		}
	}
}
